<?php
header("content-type:text/html;charset=utf8");
$username = $_POST['username'];
$goodsid = $_POST['goodsid'];
$con = mysqli_connect("localhost","root","root","2014");
mysqli_query($con,"set names utf8");
$res = mysqli_query($con,"select * from history where username='$username' and goodsid=$goodsid");
$row = mysqli_fetch_assoc($res);
if($row){
    mysqli_query($con,"delete from history where id=".$row['id']);
}
mysqli_query($con,"insert history(username,goodsid) values('$username',$goodsid)");

